package edu.cs3240.nfa;

import java.util.ArrayList;

public class Transition {
	private State from;
	private State to;
	private ArrayList<CharacterSet> transLetters;
	
	public Transition(State from, State to)
	{
		this.from = from;
		this.to = to;
		transLetters = new ArrayList<CharacterSet>();
		transLetters.add(new CharacterSet('~'));
	}
	public Transition(State from, State to, char letter)
	{
		this.from = from;
		this.to = to;
		transLetters = new ArrayList<CharacterSet>();
		transLetters.add(new CharacterSet(letter));
		
	}
	public Transition(State from, State to, ArrayList<CharacterSet> transLetters)
	{
		this.from = from;
		this.to = to;
		this.transLetters = transLetters;
	}
	
	/**
	 * Changes the destination of this transition
	 */
	public void pointTo(State end)
	{
		to = end;
	}
	
	/**
	 * Is this transition connected to a start and end state
	 * @return
	 */
	public boolean isConnected()	
	{
		return to != null;
	}

	/**
	 * The state this transition is going to
	 * @return
	 */
	public State getTo()
	{
		return to;
	}
	
	@Override
	public String toString()
	{
		if(transLetters != null && transLetters.size() > 0)
		{
			return transLetters.get(0).toString();
		}
		else
			return "";
	}
}
